<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>03_JS的数据类型</title>
</head>
<body>
<script>
    //数据类型 = 原始数据类型 + 引用数据类型
    //原始数据类型：number string boolean null undefined
    var a = 1;
    var b = 3.14;
    console.log(typeof a , typeof b)//number number
    var c = "hello"
    var d = 'world';
    console.log(typeof c , typeof d)//string string
    var e = true;
    var f = false;
    console.log(typeof e , typeof f)//boolean boolean
    var g ;//声明了变量 但未赋值,推断不出来类型,就是未定义型
    console.log(typeof g)//undefined未定义型


    //引用类型：Object Array Function Date
    let obj = {};
    console.log(obj);//{}
    console.log(typeof Obj);//object
    obj.name = "张三";
    obj.age = 18;
    console.log(obj);
    console.log(obj.name,obj.age);


    let obj2 = {
        name:"张三",
        age:18
    };
    console.log(obj2);
    obj2.like = "football";
    console.log(obj2);
    console.log(obj2.name,obj2.age,obj2.like);
    console.log(obj2.play);//访问对象不存在的属性,会的到undefined

    //数组
    let arr = [1,2.33,'3',true];
    console.log(arr);
    console.log(arr[0],arr[1],arr[2],arr[3]);
    console.log(arr[100]);//访问数组不存在的下标 ,会得到undefined

    //Number():将参数转为数字类型的结果,如果得不到数字类型的结果会的到NaN（Not a Number）
    console.log(Number(true)); //1
    console.log(Number(false));//0
    console.log(Number("123"));//123
    console.log(Number(23.45));//23.45
    console.log(Number("哈哈哈哈哈"));//NaN

    //Boolean():将参数转为布尔类型的结果
    //0,null,undefined,NaN,''会得到false
    console.log(Boolean(0));
    console.log(Boolean(null));
    console.log(Boolean(undefined));
    console.log(Boolean(NaN));
    console.log(Boolean(''));
    console.log(Boolean('hhhhh'));
    console.log(Boolean(' '));
    console.log(Boolean(1));





</script>
</body>
</html>